package com.xms.security.service.dataauth;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xms.datacore.service.FinderService;
import com.xms.security.entity.EntityPermission;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 * EntityPermissionFinderService
 * </p>
 *
 * @author migo
 * @since 2021/10/8
 */
@CacheConfig(cacheNames = "entitypermission", keyGenerator = "CacheKeyGenerator")
@Service
public class EntityPermissionFinderService extends FinderService<EntityPermission> implements IEntityPermissionFinderService {

    @Cacheable()
    @Override
    public List<EntityPermission> getByEntityId(UUID entityid) {
        return super.list(new LambdaQueryWrapper<EntityPermission>().eq(EntityPermission::getEntityid, entityid)
        .orderByAsc(EntityPermission::getAccessright));
    }
    @Override
    @Cacheable(condition="#id != null")
    public EntityPermission getById(UUID id) {
        return super.getById(id);
    }

    @Override
    @Cacheable()
    public List<EntityPermission> getByIds(Collection<UUID> idList) {
        return super.listByIds(idList);
    }

    @Override
    @Cacheable()
    public EntityPermission getOne(Wrapper<EntityPermission> queryWrapper) {
        return super.getOne(queryWrapper);
    }

    @Override
    @Cacheable()
    public int count() {
        return super.count();
    }

    @Override
    @Cacheable()
    public int count(Wrapper<EntityPermission> queryWrapper) {
        return super.count(queryWrapper);
    }

    @Override
    @Cacheable()
    public List<EntityPermission> list(Wrapper<EntityPermission> queryWrapper) {
        return super.list(queryWrapper);
    }

    @Override
    @Cacheable()
    public List<EntityPermission> all() {
        return super.list();
    }
}
